package com.xingkeduo.business.operation.controller.api;

import com.xingkeduo.business.operation.controller.InitController;
import com.xingkeduo.business.operation.domain.ManagerDomain;
import com.xingkeduo.pojo.query.ManagerQuery;
import com.xingkeduo.pojo.table.ManagerTable;
import com.xingkeduo.tool.ResponseUtils;
import com.xingkeduo.util.pojo.exception.SystemException;
import com.xingkeduo.util.tool.ReturnUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.xingkeduo.tool.OperaConstants.API_URL_PREFIX;

@RestController
@RequestMapping(API_URL_PREFIX +"/manager")
public class ManagerApiController extends InitController {
    @Autowired
    private ManagerDomain managerDomain;

    @GetMapping(value = "/lists")
    public ResponseUtils doGetLists(ManagerQuery managerQuery) {
        returnUtil = new ReturnUtil();
        try {
            List<ManagerTable> citiesList= managerDomain.getManagerList(managerQuery);
            return ResponseUtils.getSuccess(citiesList);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            return ResponseUtils.error(throwable.getMessage(), SystemException.Type.DEFAULT.toString());
        }
    }

}
